import 'package:auntserver/application.dart';
import 'package:auntserver/router_handler/router_handler.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

///定义页面
class Routes {
  static String root = "/";
  static String splash = '/splash';
  static String chooseIdentity = '/chooseIdentity';
  static String inputPhone = '/inputPhone';
  static String inputPassword = '/inputPassword';
  static String main = '/main';
  static String precious = '/precious';
  static String orderDetail = '/orderDetail';

  static void configureRoutes(FluroRouter router) {
    router.notFoundHandler = emptyHandler;
    router.define(precious, handler: preciousHandler);
    router.define(splash, handler: splashHandler);
    router.define(chooseIdentity, handler: chooseIdentityHandler);
    router.define(inputPhone, handler: inputPhoneHandler);
    router.define(inputPassword, handler: inputPasswordHandler);
    router.define(main, handler: mainHandler);
    router.define(orderDetail, handler: orderDetailHandler);
  }

// 返回
  static void goBack(BuildContext context) {
    /// 其实这边调用的是
    Navigator.pop(context);
    AuntApp.router.pop(context);
  }

  // 带参数的返回
  static void goBackWithParams(BuildContext context, result) {
    Navigator.pop(context, result);
  }

  // 路由返回指定页面
  static void goBackUrl(BuildContext context, String title) {
    Navigator.popAndPushNamed(context, title);
  }

  // 跳转到主页面
  static void goHomePage(BuildContext context) {
    AuntApp.router.navigateTo(context, Routes.main, replace: true);
  }

  /// 跳转到 转场动画 页面 ， 这边只展示 inFromLeft ，剩下的自己去尝试下，
  /// 框架自带的有 native，nativeModal，inFromLeft，inFromRight，inFromBottom，fadeIn，custom
  static Future jump(BuildContext context, String title) {
    return AuntApp.router
        .navigateTo(context, title, transition: TransitionType.inFromRight);
  }



  // static Future jumpRemove(BuildContext context) {
  //   return Navigator.of(context).pushAndRemoveUntil(
  //       MaterialPageRoute(
  //         builder: (context) => IndexPage(),
  //       ),
  //       (route) => route == null);
  // }
  //
  // // 跳转到主页面IndexPage并删除当前路由
  // static void goToHomeRemovePage(BuildContext context) {
  //   Navigator.of(context).pushAndRemoveUntil(
  //       MaterialPageRoute(
  //         builder: (context) => IndexPage(),
  //       ),
  //       (route) => route == null);
  // }
  //
  // // 跳转到登录页并删除当前路由
  // static void goToLoginRemovePage(BuildContext context) {
  //   Navigator.of(context).pushAndRemoveUntil(
  //       MaterialPageRoute(
  //         builder: (context) => Login(),
  //       ),
  //       (route) => route == null);
  // }
}
